/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_ESPE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbEspe.findAll", query = "SELECT a FROM AmTbEspe a"),
    @NamedQuery(name = "AmTbEspe.findByCdEspe", query = "SELECT a FROM AmTbEspe a WHERE a.cdEspe = :cdEspe"),
    @NamedQuery(name = "AmTbEspe.findByNmEspe", query = "SELECT a FROM AmTbEspe a WHERE a.nmEspe = :nmEspe")})
public class AmTbEspe implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_ESPE")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_ESPE")
    @SequenceGenerator(name="seq_AM_TB_ESPE", sequenceName = "seq_AM_TB_ESPE")
    private Short cdEspe;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "NM_ESPE")
    private String nmEspe;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbEspe")
    private Collection<AmTbMediEspe> amTbMediEspeCollection;

    public AmTbEspe() {
    }

    public AmTbEspe(Short cdEspe) {
        this.cdEspe = cdEspe;
    }

    public AmTbEspe(Short cdEspe, String nmEspe) {
        this.cdEspe = cdEspe;
        this.nmEspe = nmEspe;
    }

    public Short getCdEspe() {
        return cdEspe;
    }

    public void setCdEspe(Short cdEspe) {
        this.cdEspe = cdEspe;
    }

    public String getNmEspe() {
        return nmEspe;
    }

    public void setNmEspe(String nmEspe) {
        this.nmEspe = nmEspe;
    }

    @XmlTransient
    public Collection<AmTbMediEspe> getAmTbMediEspeCollection() {
        return amTbMediEspeCollection;
    }

    public void setAmTbMediEspeCollection(Collection<AmTbMediEspe> amTbMediEspeCollection) {
        this.amTbMediEspeCollection = amTbMediEspeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdEspe != null ? cdEspe.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbEspe)) {
            return false;
        }
        AmTbEspe other = (AmTbEspe) object;
        if ((this.cdEspe == null && other.cdEspe != null) || (this.cdEspe != null && !this.cdEspe.equals(other.cdEspe))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbEspe[ cdEspe=" + cdEspe + " ]";
    }
    
}
